<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
</head>
<style>
    html,
    body {
        background-color: #fff;
    }

    .placeholder_div {
        background-color: #fbf9f9;
    }

    .padding {
        padding: 1rem 0.8rem 0 0.8rem;
    }

    .search_input {
        width: 95%;
        padding-left: 5%;
        background-color: #F7F7F7;
        height: 2rem;
        line-height: 2rem;
        font-size: 0.7rem;
        color: #BBBABA;
        border-radius: 0.5rem;
        outline: none;
    }

    .order_div {
        width: 100%;
    }

    .order_div .order_item {
        padding: 1rem 0;
        border-bottom: 1px solid #E8E8E8;
    }


    .order_div .order_item .order_title {
        color: #565656;
        font-size: 0.7rem;
    }

    .order_div .order_item .order_title span {
        display: inline-block;
        padding: 0.25rem 0.5rem;
        border: 1px solid #2780e8;
        border-radius: 1rem;
        font-size: 0.5rem;
        color: #838383;
        margin-left: 1.5rem;
    }

    .order_div .order_item .order_useing {
        color: #838383;
        font-size: 0.6rem;
        margin-top: 0.75rem;
    }

    .order_div .order_item img {
        width: 0.7rem;
        height: 0.7rem;
        float: right;
    }

    .none {
        font-size: 14px;
        margin: 0.5rem 0;
        text-align: center;
    }
</style>

<body>
    <div id="app" v-cloak>
        <div class="placeholder_div"></div>
        <div class="padding">
            <input type="text" class="search_input" placeholder="搜索方名、药名">

            <div class="order_div">

                <div class="order_item" v-for="item in fangan_info" v-if="index == 11">
                    <img src="../image/back_icon.png" @click="del(item.id)" alt="">
                    <div @click="go_add_yaocai_win(item)" class="order_item-box">
                        <p class="order_title">{{item.name}}

                        </p>
                        <p class="order_useing">{{item.remark}}</p>
                    </div>
                </div>

                <div class="order_item" @click="add_my_always_useing_win(item.id)" v-for="item in fangan_info"
                    v-if="index == 1">
                    <img src="../image/back_icon.png" @click="del(item.id)" alt="">
                    <p class="order_title">{{item.name}}
                        <!-- <span>中药饮片</span> -->
                    </p>
                    <p class="order_useing">{{item.remark}}</p>
                </div>



                <p class="none">已经没有更多了~</p>
            </div>
        </div>
    </div>
</body>

</html>
<script src="../script/set_root.js"></script>

<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hb.js"></script>
<script type="text/javascript" src="../script/vue.js"></script>
<script type="text/javascript">
    apiready = function () {
        hb_ready();

        app.index = api.pageParam.index
        // alert(app.index)
        getdata() // 获得常用方所有数据

        api.addEventListener({
            name: 'add_my_always_useing'
        }, function (ret, err) {
            getdata()
        });
    }
    //使用vue对数据进行绑定
    var app = new Vue({
        el: '#app',
        data: {
            page: 1,
            fangan_info: [], // 方案数组
            index: 0,
        },
        methods: {
            del: function (id) {
                get_ajax("doctor/frequent/delete", {
                    id: id,
                }, function (ret, err) {
                    if (ret.code == 200) {
                        toast(ret.msg)
                        getdata()
                    } else {
                        toast("请求数据异常，请稍后再试！")
                    }
                    if (err) {
                        alert("网络不通畅，请稍后再试！")
                    }
                })
            },
            add_my_always_useing_win: function (id) {
                api.openWin({
                    name: "add_my_always_useing_win",
                    url: "add_my_always_useing_win.html",
                    pageParam: {
                        id: id
                    }
                })
            },
            go_add_yaocai_win: function (item) {
                get_ajax("doctor/frequent/view", {
                    id: item.id
                }, function (res, err) {
                    if (res.code == 200) {
                        // alert(JSON.stringify(res))
                        sendting_zhi("fasong_yaocai", res.data.frequentItemVoList)
                        api.closeWin()
                    } else {
                        alert("网络不通畅，请稍后再试！")
                    }
                })
            }
        },

    })

    function getdata() {
        get_ajax("doctor/frequent/list/page", {
            userId: $api.getStorage("emp").userId,
            page: app.page,
            pagesize: 10,
        }, function (ret, err) {
            // alert(JSON.stringify(ret))
            if (ret.code == 2000) {
                app.fangan_info = ret.data.data
                app.$nextTick(function () {
                    hb_init_openwinby_click();
                })
            } else {
                alert("请求数据异常，请稍后再试！")
            }
            // if (err) {
            //     alert("网络不通畅，请稍后再试！")
            // }
        })
    }
</script>